home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’96 / Booting Gallery / Booting Gallery (source) / iconhack Folder / StandardHeader.h < prev   
Encoding:
C/C++ Source or Header  |  1996-06-22  |  4.8 KB  |  170 lines  |  [TEXT/KAHL]

  1. #pragma once
  2.  
  3. typedef unsigned char uchar;
  4. typedef unsigned short ushort;
  5. typedef unsigned long ulong;
  6.  
  7. extern Point Mouse : 0x830;
  8.  
  9. extern struct Keyboard {
  10.     short    wasted;
  11.     short    wasted2;
  12.     short    wasted3;
  13.     int command : 1;
  14.     int : 5;
  15.     int space : 1;
  16.     int tab : 1;
  17.     int : 4;
  18.     int control : 1;
  19.     int option : 1;
  20.     int capslock : 1;
  21.     int shift : 1;
  22. } keymap : 0x174;
  23.  
  24.     // this structure is useful for interpreting the fdFlags field of the FInfo structure.
  25. typedef struct {
  26.     int isAlias        : 1;
  27.     int isInvisible : 1;
  28.     int hasBundle    : 1;
  29.     int nameLocked    : 1;
  30.     int isStationery: 1;
  31.     int hasCustomIcn: 1;
  32.     int             : 1;
  33.     int wasInited    : 1;
  34.     int hasNoINITS    : 1;
  35.     int isShared    : 1;
  36.     int SwitchLaunch: 1;
  37.     int             : 1;
  38.     int color       : 3;
  39.     int             : 1;
  40. } FileFlags;
  41.  
  42. #define topLeft(r) (*(Point *)&r.top)
  43. #define botRight(r) (*(Point *)&r.bottom)
  44.  
  45. // SetA4 is an inline for setting register a4 without using inline assembly.
  46. // it returns the old value of a4.
  47.  
  48. #pragma parameter __A0 SetA4(__A0)
  49. pascal void *SetA4(void *newA4) = 0xC948;
  50.  
  51. // CopyHandle is a better interface to HandToHand.
  52.  
  53. #pragma parameter __A0 CopyHandle(__A0)
  54. pascal void *CopyHandle(void *) = {0xA9E1};
  55.  
  56. // jbGetHandleSize is just GetHandleSize, without the error checks.
  57.  
  58. #pragma parameter __D0 jbGetHandleSize(__A0)
  59. pascal long jbGetHandleSize(void *h) = 0xA025;
  60.  
  61. // HandleOf is a better interface to PtrToHand
  62.  
  63. #pragma parameter __A0 HandleOf(__A0, __D0)
  64. pascal void *HandleOf(void *, long) = {0xA9E3};
  65.  
  66. // ClearSpace is a trivial inline for clearing space out.
  67.  
  68. // ••• WARNING!  DO NOT USE THESE IF THERE IS ANY CHANCE OF CLEARING ZERO BYTES!
  69. // ••• THESE INLINES OPERATE FOR SPEED'S SAKE AND WILL CLEAR TOO MUCH SPACE IF
  70. // ••• YOU PASS ZERO.
  71.  
  72. #pragma parameter ClearSpace(__A0, __D0)
  73. pascal void ClearSpace(void *, long) = {0x4218, 0x5380, 0x62FA};
  74.  
  75. #pragma parameter ClearSpace2(__A0, __D1)
  76. pascal void ClearSpace2(void *, long) = {0x7000, 0x30C0, 0x5541, 0x62FA};
  77.  
  78. #pragma parameter ClearSpace4(__A0, __D1)
  79. pascal void ClearSpace4(void *, long) = {0x7000, 0x20C0, 0x5981, 0x62FA};
  80.  
  81. // QuickMove is faster than BlockMove for very small moves.
  82.  
  83. #pragma parameter QuickMove(__A0, __A1, __D0)
  84. pascal void QuickMove(void *from, void *to, short bytes) = {0x12D8, 0x5340, 0x62FA};
  85.  
  86. // MakeALong makes a long out of two shorts efficiently.
  87.  
  88. #pragma parameter __D0 MakeALong(__D0, __D1)
  89. pascal long MakeALong(short HiWord, short LoWord) = {0x4840, 0x3001};
  90.  
  91. // MinShort takes the minimum of two input shorts efficiently
  92.  
  93. #pragma parameter __D0 MinShort(__D0, __D1)
  94. pascal short MinShort (short a, short b) = {0xB240, 0x6E02, 0x3001};
  95.  
  96. // MaxShort takes the maximum of two input shorts efficiently
  97.  
  98. #pragma parameter __D0 MaxShort(__D0, __D1)
  99. pascal short MaxShort (short a, short b) = {0xB240, 0x6D02, 0x3001};
  100.  
  101. // jbLoWord quickly retrieves the low word of a long..
  102.  
  103. #define jbLoWord(l) ((short)(l))
  104.  
  105. // jbHiWord quickly retrieves the high word of a long..
  106.  
  107. #pragma parameter __D0 jbHiWord(__D0)
  108. pascal short jbHiWord(long Long) = {0x4840};
  109.  
  110. // jbxDelay is a better interface for Delay.
  111.  
  112. #pragma parameter __A0 jbxDelay(__A0)
  113. pascal long jbxDelay(long numTicks)
  114.     = {0xA03B}; 
  115.  
  116. // PenWhite calls PenPat(white) from QuickDraw's globals.
  117.  
  118. pascal void PenWhite(void)
  119.     =    {0x2055, 0x4868, 0xFFF8, 0xA89D};
  120.  
  121. // PenBlack calls PenPat(black) from QuickDraw's globals.
  122.  
  123. pascal void PenBlack(void)
  124.     =    {0x2055, 0x4868, 0xFFF0, 0xA89D};
  125.  
  126. // PenGray calls PenPat(gray) from QuickDraw's globals.
  127.  
  128. pascal void PenGray(void)
  129.     =    {0x2055, 0x4868, 0xFFE8, 0xA89D};
  130.  
  131. // ArrowCursor calls SetCursor(arrow) from QuickDraw's globals.
  132.  
  133. pascal void ArrowCursor(void)
  134.     =    {0x2055, 0x4868, 0xFF94, 0xA851};
  135.  
  136. // PStringMove is a quick pascal string copy using the toolbox.
  137.  
  138. #pragma parameter PStringMove(__A0,__A1)
  139. pascal void PStringMove(const void *srcPtr,void *destPtr)
  140.     = {0x7001, 0xD010, 0xA02E}; 
  141.  
  142. // Why HOpenResFile isn't declared this way, I don't know.
  143. // (Under System 7, HORF has its own trap)
  144.  
  145. pascal short HOpenResFile7(short vRefNum,long dirID,ConstStr255Param fileName,
  146.     char permission) = 0xA81A;
  147.  
  148. // a quicker inline for access to NumToString when you need it:
  149.  
  150. #pragma parameter iNumToString(__D0, __A0)
  151. pascal void iNumToString(long theNum, void *theString) = {0x4267, 0xA9EE};
  152.  
  153. // a quicker inline for access to StringToNum when you need it:
  154.  
  155. #pragma parameter __D0 iStringToNum(__A0)
  156. pascal long iStringToNum(void *theString) = {0x3F3C, 0x0001, 0xA9EE};
  157.  
  158. // iRelString is an interface to the RelString trap.  It returns a result such
  159. // that "iRelString(s1, s2) > 0" returns the same as "s1 > s2", that is, zero
  160. // if the strings are equal, 1 if s1 is greater that s2, -1 if neither.
  161.  
  162. #pragma parameter __D0 iRelString(__A0, __A1)
  163. pascal short iRelString(void *first, void *second) = {
  164.     0x7000,    // moveq    #0,d0
  165.     0x1018,    // move.b    (a0)+,d0
  166.     0x4840,    // swap        d0
  167.     0x1019,    // move.b    (a1)+,d0
  168.     0xA050    // RelString
  169. };
  170.